package com.cykj.page02.servlet;

import com.cykj.page02.MyHttpRequest;
import com.cykj.page02.MyHttpResponse;

/**
 * @BelongsProject: HandTomcat
 * @BelongsPackage: com.cykj.page02.servlet
 * @Author: 阿隆
 * @CreateTime: 2025-10-25 11:44
 * @Description: 基本servlet
 * @Version: 1.0
 */
public abstract class BaseServlet {


    protected abstract void doGet(MyHttpRequest httpRequest, MyHttpResponse httpResponse);


    protected abstract void doPost(MyHttpRequest httpRequest, MyHttpResponse httpResponse);


    /**
     * @Description: 请求方法的判断
     * @Param: [httpRequest, httpResponse]
     * @return: void
     */
    public void requestMethodHandler(MyHttpRequest httpRequest, MyHttpResponse httpResponse) {
        if ("GET".equals(httpRequest.getRequestMethod())) {
            doGet(httpRequest, httpResponse);
        } else if ("POST".equals(httpRequest.getRequestMethod())) {
            doPost(httpRequest, httpResponse);
        }

    }
}